home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9403 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  63 lines

  1. Newsgroups: comp.lang.ada,comp.lang.c++
  2. Path: news3.near.net!inmet!henning!stt
  3. From: stt@henning.camb.inmet.com (Tucker Taft)
  4. Subject: Re: on OO differnces between Ada95 and C++
  5. X-Nntp-Posting-Host: henning.camb.inmet.com
  6. Message-ID: <DnLIEx.M2C.0.-s@inmet.camb.inmet.com>
  7. Followup-To: comp.lang.ada,comp.lang.c++
  8. Sender: news@inmet.camb.inmet.com (USENET news)
  9. Organization: Intermetrics, Inc.
  10. X-Newsreader: TIN [version 1.1 PL8]
  11. References: <4h5ej5$168@wdl1.wdl.loral.com>
  12. Date: Fri, 1 Mar 1996 15:44:56 GMT
  13.  
  14. Mark A Biggar (mab@dst17.wdl.loral.com) wrote:
  15. : >In article <DnDuA4.8GC@bton.ac.uk>, je@bton.ac.uk (John English) writes: 
  16. : >Furthermore, for the convenience of its clients, X can contain a
  17. : >declaration such as
  18. : >
  19. : >   subtype T is Y.T;
  20. : >
  21. : >which causes X to reexport the type originally declared in Y.  Then X's
  22. : >client can refer to the type (as X.T) without a with clause for Y.
  23.  
  24. : How does this interact with "use type T;"?
  25.  
  26. Fine.  "Use type" allows any subtype to be specified, and it
  27. makes the primitive operators of the subtype's type (the type
  28. "determined" by "T") directly visible.  There really is no 
  29. special case here, since only subtypes have names in Ada 95; 
  30. even Y.T is a "subtype_mark."
  31.  
  32. : Does the following work?
  33.  
  34. Yes.
  35.  
  36. : package A is
  37. :     type T is new integer;
  38. :     function "+"(L,R: T) return T;
  39. : end A;
  40.  
  41. : with A;
  42. : package B is
  43. :     subtype T is A.T;
  44. : end B;
  45.  
  46. : with B;
  47. : procedure C is
  48. :     X: B.T;
  49. :     use type B.T;
  50. : begin
  51. :     X := X + X;   --- what "+" operator do I get here if any?
  52.  
  53. The primitive "+" of the B.T's type, which is the one declared in 
  54. package A.
  55.  
  56. : end C;
  57.  
  58. : Mark Biggar
  59. : mab@wdl.loral.com
  60.  
  61. -Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
  62. Intermetrics, Inc.  Cambridge, MA  USA
  63.